from datetime import timedelta
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    # === MySQL ===
    DB_HOST: str = "10.89.23.253"
    DB_PORT: int = 3306
    DB_USER: str = "root"
    DB_PASSWORD: str = "Gg123456789!"
    DB_NAME: str = "eduManage"

    # === JWT ===
    SECRET_KEY: str = "replace-with-a-strong-secret-key"   # 生产用 openssl rand -hex 32
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24

    # Tortoise 配置
    @property
    def DATABASE_URL(self):
        return f"mysql://{self.DB_USER}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"

    class Config:
        env_file = ".env"      # 允许被 .env 覆盖

settings = Settings()          # 单例